home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat5 / mmci.z / mmci
Encoding:
Text File  |  2001-04-17  |  49.9 KB  |  1,127 lines

  1.  
  2.  
  3.  
  4. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      mmci - Memory Management Control Interface
  10.  
  11. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  12.      This document describes the concepts and interfaces provided by IRIX for
  13.      fine tuning memory management policies for user applications.
  14.  
  15.    PPPPoooolllliiiiccccyyyy MMMMoooodddduuuulllleeeessss
  16.      The ability of applications to control memory management becomes an
  17.      essential feature in multiprocessors with a CCNUMA memory system
  18.      architecture. For most applications, the operating system is capable of
  19.      producing reasonable levels of locality via dynamic page migration and
  20.      replication; however, in order to maximize performance, some applications
  21.      may need fine tuned memory management policies.
  22.  
  23.      We provide a Memory Management Control Interface based on the
  24.      specification of policies for different kinds of operations executed by
  25.      the Virtual Memory Management System. Users are allowed to select a
  26.      policy from a set of available policies for each one of these VM
  27.      operations. Any portion of a virtual address space, down to the level of
  28.      a page, may be connected to a specific policy via a Policy Module.
  29.  
  30.      A policy module or PM contains the policy methods used to handle each of
  31.      the operations shown in the table below.
  32.  
  33.        MEMORY OPERATION          POLICY                  DESCRIPTION
  34.       _______________________________________________________________________
  35.       Initial Allocation   Placement Policy     Determines what physical
  36.                                                 memory node to use when
  37.                                                 memory is allocated
  38.                            Page Size Policy     Determines what virtual page
  39.                                                 size to use to map physical
  40.                                                 memory
  41.                            Fallback Policy      Determines the relative
  42.                                                 importance between placement
  43.                                                 and page size
  44.       _______________________________________________________________________
  45.       Dynamic Relocation   Migration Policy     Determines the aggressiveness
  46.                                                 of memory migration
  47.                            Replication Policy   Determines the aggressiveness
  48.                                                 of replication
  49.       _______________________________________________________________________
  50.       Paging               Paging Policy        Determines the aggressiveness
  51.                                                 and domain of memory paging
  52.  
  53.      When the operating system needs to execute an operation to manage a
  54.      section of a process' address space, it uses the methods specified by the
  55.      Policy Module connected (attached) to that section.
  56.  
  57.      To allocate a physical page, the VM system physical memory allocator
  58.      first calls the method provided by the Placement Policy that determines
  59.      where the page should be allocate from. Internally, this method returns a
  60.      handle identifying the node memory should be allocated from. The
  61.      Placement Policy is described in detail later in this document.
  62.  
  63.  
  64.                                                                         PPPPaaaaggggeeee 1111
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  72.  
  73.  
  74.  
  75.      Second, the physical memory allocator determines the page size to be used
  76.      for the current allocation. This page size is acquired using a method
  77.      provided by the Page Size Policy. Now, knowing both the source node and
  78.      the page size, the physical memory allocator calls a per-node memory
  79.      allocator specifying both parameters. If the system finds memory on this
  80.      node that meets the page size requirement, the allocation operation
  81.      finishes successfully; if not, the operation fails, and a fallback method
  82.      specified by the Fallback Policy is called. The fallback method provided
  83.      by this policy decides whether to try the same page size on a different
  84.      node, a smaller page size on the same source node, sleep, or just fail.
  85.  
  86.      The Fallback Policy to choose depends on the kind of memory access
  87.      patterns an application exhibits. If the application tends to generate
  88.      lots of cache misses, giving locality precedence over the page size may
  89.      make sense; otherwise, especially if the application's working set is
  90.      large, but has reasonable cache behavior, giving the page size higher
  91.      precedence may make sense.
  92.  
  93.      Once a page has been placed, it stays on its source node until it is
  94.      either migrated to a different node, or paged out and faulted back in.
  95.      Migratability of a page is determined by the migration policy. For some
  96.      applications, those that present a very uniform memory access pattern
  97.      from beginning to end, initial placement may be sufficient and migration
  98.      can be turned off; on the other hand, applications with phase changes can
  99.      really benefit from some level of dynamic migration, which has the effect
  100.      of attracting memory to the nodes where it's being used.
  101.  
  102.      Read-only text can also be replicated. The degree of replication of text
  103.      is determined by the Replication policy. Text shared by lots of processes
  104.      running on different nodes may benefit substantially from several
  105.      replicas which both provide high locality and minimize interconnect
  106.      contention. For example /bin/sh may be a good candidate to replicate on
  107.      several nodes, whereas programs such as /bin/bc really don't need much
  108.      replication at all.
  109.  
  110.      Finally, all paging activity is controlled by the Paging Policy. When a
  111.      page is about to be evicted, the pager uses the Paging Policy Methods in
  112.      the corresponding PM to determine whether the page can really be stolen
  113.      or not.  Further, this policy also controls page replacement.
  114.  
  115.      The current version of IRIX provides the policies shown in the table
  116.      below.
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.                                                                         PPPPaaaaggggeeee 2222
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  138.  
  139.  
  140.  
  141.            POLICY TYPE           POLICY NAME              ARGUMENTS
  142.         __________________________________________________________________
  143.         Placement Policy     PlacementDefault       Number Of Threads
  144.                              PlacementFixed         Memory Locality Domain
  145.                              PlacementFirstTouch    No Arguments
  146.                              PlacementRoundRobin    Roundrobin Mldset
  147.                              PlacementThreadLocal   Application Mldset
  148.                              PlacementCacheColor    Memory Locality Domain
  149.         __________________________________________________________________
  150.         Fallback Policy      FallbackDefault        No Arguments
  151.                              FallbackLargepage      No Arguments
  152.         __________________________________________________________________
  153.         Replication Policy   ReplicationDefault     No Arguments
  154.                              ReplicationOne         No Arguments
  155.         __________________________________________________________________
  156.         Migration Policy     MigrationDefault       No Arguments
  157.                              MigrationControl       migr_policy_uparms_t
  158.                              MigrationRefcnt        No Arguments
  159.         __________________________________________________________________
  160.         Paging Policy        PagingDefault          No Arguments
  161.         __________________________________________________________________
  162.         Page Size Policy     -                      Page size
  163.         __________________________________________________________________
  164.  
  165.      The following list briefly describes each policy.
  166.  
  167.      PlacementDefault      This policy automatically creates and places an MLD
  168.                            for every two processes in a process group on an
  169.                            Origin 2000. For the Origin 3000 this policy
  170.                            creates and places an MLD for every four processes
  171.                            in a process group. The number of processes is
  172.                            provided as a passed in argument.  Each process's
  173.                            memory affinity link (memory affinity hint used by
  174.                            the process scheduler) is automatically set to the
  175.                            MLD created on behalf of the process. The MLD(s)
  176.                            estimate a memory affinity hint based on the size
  177.                            of the currently running process address space.
  178.                            Memory is allocated by referencing the MLD being
  179.                            used as the memory affinity link for the currently
  180.                            running process. By using this policy the
  181.                            application does not need to create and place
  182.                            MLD(s) or an MLDSET.
  183.  
  184.      PlacementFixed        This policy requires a placed MLD to be passed as
  185.                            an argument. All memory allocation is done using
  186.                            the node where the MLD has been placed.
  187.  
  188.      PlacementFirstTouch   This policy starts with the creation of one MLD,
  189.                            placing it on the node where creation happened. All
  190.                            memory allocation is done using the node where the
  191.                            MLD has been placed.
  192.  
  193.      PlacementRoundRobin   This policy requires a placed MLDSET to be passed
  194.                            as an argument. Memory allocation happens in a
  195.                            round robin fashion over each one of the MLDs in
  196.                            the MLDSET. The policy maintains a round robin
  197.  
  198.  
  199.                                                                         PPPPaaaaggggeeee 3333
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  207.  
  208.  
  209.  
  210.                            pointer that points to the next MLD to be used for
  211.                            memory allocation, which is moved to point to the
  212.                            next MLD in the MLDSET after every successful
  213.                            memory allocation. Note that the round robin
  214.                            operation is done in the time axis, not the space
  215.                            axis.
  216.  
  217.      PlacementThreadLocal  This policy requires a placed MLDSET to be passed
  218.                            as an argument. The application has to set the
  219.                            affinity links for all processes in the process
  220.                            group. Memory is allocated using the MLD being used
  221.                            as the memory affinity link for the currently
  222.                            running process.
  223.  
  224.      PlacementCacheColor   This policy requires a placed MLD to be passed as
  225.                            an argument. The application is responsible for
  226.                            setting the memory affinity links. Memory is
  227.                            allocated using the specified MLD, with careful
  228.                            attention to cache coloring relative to the Policy
  229.                            Module instead of the global virtual address space.
  230.  
  231.      FallbackDefault       The default fallback policy gives priority to
  232.                            locality. We first try to allocate a base page
  233.                            (16KB in Origin systems) on the requested node. If
  234.                            no memory is available on that node, we borrow from
  235.                            some close neighbor, following a spiral search
  236.                            path.
  237.  
  238.      FallbackLargepage     When this fallback policy is selected, we give
  239.                            priority to the page size. We first try to allocate
  240.                            a page of the requested size on a nearby node, and
  241.                            fallback to a base page only if a page of this size
  242.                            is not available on any node in the system.
  243.  
  244.      ReplicationDefault    When this policy is selected, read-only pages are
  245.                            replicated following the _C_o_v_e_r_a_g_e _R_a_d_i_u_s algorithm
  246.                            described in replication(5).
  247.  
  248.      ReplicationOne        Force the system to use only one replica.
  249.  
  250.      MigrationDefault      When this default migration policy is selected,
  251.                            migration behaves as explained in migration(5)
  252.                            according to the tunable parameters also described
  253.                            in migration(5).
  254.  
  255.      MigrationControl      Users can select different migration parameters
  256.                            when using this policy. It takes an argument of
  257.                            type migr_policy_uparms_t shown below.
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.                                                                         PPPPaaaaggggeeee 4444
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  273.  
  274.  
  275.  
  276.                            typedef struct migr_policy_uparms {
  277.                                    __uint64_t  migr_base_enabled         :1,
  278.                                                migr_base_threshold       :8,
  279.                                                migr_freeze_enabled       :1,
  280.                                                migr_freeze_threshold     :8,
  281.                                                migr_melt_enabled         :1,
  282.                                                migr_melt_threshold       :8,
  283.                                                migr_enqonfail_enabled    :1,
  284.                                                migr_dampening_enabled    :1,
  285.                                                migr_dampening_factor     :8,
  286.                                                migr_refcnt_enabled       :1; }
  287.                            migr_policy_uparms_t;
  288.  
  289.                            This structure allows users to override the default
  290.                            migration parameters defined in
  291.                            /var/sysgen/mtune/numa and described in
  292.                            migration(5).
  293.  
  294.                            - mmmmiiiiggggrrrr____bbbbaaaasssseeee____eeeennnnaaaabbbblllleeeedddd enables (1) or disables (0)
  295.                              migration.
  296.  
  297.                            - mmmmiiiiggggrrrr____bbbbaaaasssseeee____tttthhhhrrrreeeesssshhhhoooolllldddd defines the migration
  298.                              threshold.
  299.  
  300.                            - mmmmiiiiggggrrrr____ffffrrrreeeeeeeezzzzeeee____eeeennnnaaaabbbblllleeeedddd enables (1) or disables (0)
  301.                              freezing.
  302.  
  303.                            - mmmmiiiiggggrrrr____ffffrrrreeeeeeeezzzzeeee____tttthhhhrrrreeeesssshhhhoooolllldddd defines the freezing
  304.                              threshold.
  305.  
  306.                            - mmmmiiiiggggrrrr____mmmmeeeelllltttt____eeeennnnaaaabbbblllleeeedddd enables (1) or disables (0)
  307.                              melting.
  308.  
  309.                            - mmmmiiiiggggrrrr____mmmmeeeelllltttt____tttthhhhrrrreeeesssshhhhoooolllldddd defines the melting
  310.                              threshold.
  311.  
  312.                            - mmmmiiiiggggrrrr____eeeennnnqqqqoooonnnnffffaaaaiiiillll____eeeennnnaaaabbbblllleeeedddd is a no-op for IRIX 6.5
  313.                              and earlier.
  314.  
  315.                            - mmmmiiiiggggrrrr____ddddaaaammmmppppeeeennnniiiinnnngggg____eeeennnnaaaabbbblllleeeedddd enables (1) or disables
  316.                              (0) dampening.
  317.  
  318.                            - mmmmiiiiggggrrrr____ddddaaaammmmppppeeeennnniiiinnnngggg____ffffaaaaccccttttoooorrrr defines the dampening
  319.                              threshold.
  320.  
  321.                            - mmmmiiiiggggrrrr____rrrreeeeffffccccnnnntttt____eeeennnnaaaabbbblllleeeedddd enables (1) or disables (0)
  322.                              extended reference counters.
  323.  
  324.      MigrationRefcnt       This policy turns migration completely off (for the
  325.                            associated section of virtual address space) and
  326.                            enables the extended reference counters.  No
  327.                            arguments are needed.
  328.  
  329.  
  330.  
  331.                                                                         PPPPaaaaggggeeee 5555
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  339.  
  340.  
  341.  
  342.      PagingDefault         This is currently the only available paging policy.
  343.                            It's the usual IRIX paging policy.
  344.  
  345.      Page Size             Users can select any of the page sizes supported by
  346.                            the processor being used. For Origin 2000 systems
  347.                            the allowed sizes are: 16KB, 64KB, 256KB, 1024KB
  348.                            (1MB), 4096KB (4MB), and 16384KB (16MB).
  349.  
  350.    CCCCrrrreeeeaaaattttiiiioooonnnn ooooffff PPPPoooolllliiiiccccyyyy MMMMoooodddduuuulllleeeessss
  351.      A policy module can be created using the following Memory Management
  352.      Control Interface call:
  353.  
  354.           typedef struct policy_set {
  355.                   char*  placement_policy_name;
  356.                   void*  placement_policy_args;
  357.                   char*  fallback_policy_name;
  358.                   void*  fallback_policy_args;
  359.                   char*  replication_policy_name;
  360.                   void*  replication_policy_args;
  361.                   char*  migration_policy_name;
  362.                   void*  migration_policy_args;
  363.                   char*  paging_policy_name;
  364.                   void*  paging_policy_args;
  365.                   size_t page_size;
  366.                             short  page_wait_timeout;
  367.                             short  policy_flags;
  368.           } policy_set_t;
  369.  
  370.           pmo_handle_t pm_create(policy_set_t* policy_set);
  371.  
  372.  
  373.      The policy_set_t structure contains all the data required to create a
  374.      Policy Module. For each selectable policy listed above, this structure
  375.      contains a field to specify the name of the selected policy and the list
  376.      of possible arguments that the selected policy may require. The page size
  377.      policy is the exception, for which the specification of the wanted page
  378.      size suffices. Pages of larger sizes reduce TLBMISS overhead and can
  379.      improve the performance of applications with large working sets. Like
  380.      other system resources large pages are not guaranteed to be available in
  381.      the system when the application makes the request. The application has
  382.      two choices. It can either wait for a specified timeout or use a page of
  383.      lower page size. The page_wait_timeout specifies the number of seconds a
  384.      process can wait for a page of the requested size to be available. If the
  385.      timeout value is zero or if the page of the requested size is not
  386.      available even after waiting for the specified timeout the system uses a
  387.      page of a lower page size.  The policy_flags field allows users to
  388.      specify special behaviors that apply to all the policies that define a
  389.      Policy Module. The only special behavior currently implemented forces the
  390.      memory allocator to prioritize cache coloring over locality, and it can
  391.      be selected using the flag PPPPOOOOLLLLIIIICCCCYYYY____CCCCAAAACCCCHHHHEEEE____CCCCOOOOLLLLOOOORRRR____FFFFIIIIRRRRSSSSTTTT. For example:
  392.  
  393.  
  394.  
  395.  
  396.  
  397.                                                                         PPPPaaaaggggeeee 6666
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  405.  
  406.  
  407.  
  408.                policy_set.placement_policy_name = "PlacementFixed";
  409.                policy_set.placement_policy_args = (void *)mld_handle;
  410.                policy_set.fallback_policy_name = "FallbackDefault";
  411.                policy_set.fallback_policy_args = NULL;
  412.                policy_set.replication_policy_name = "ReplicationDefault";
  413.                policy_set.replication_policy_args = NULL;
  414.                policy_set.migration_policy_name = "MigrationDefault";
  415.                policy_set.migration_policy_args = NULL;
  416.                policy_set.paging_policy_name = "PagingDefault";
  417.                policy_set.paging_policy_args = NULL;
  418.                policy_set.page_size = PM_PAGESZ_DEFAULT;
  419.                policy_set.page_wait_timeout = 0;
  420.                policy_set.policy_flags = POLICY_CACHE_COLOR_FIRST;
  421.  
  422.  
  423.      This example is filling up the policy_set_t structure to create a PM with
  424.      a placement policy called "PlacementFixed" which takes a Memory Locality
  425.      Domain (MLD) as an argument. All other policies are set to be the default
  426.      policies, including the page size. We also ask for cache coloring to be
  427.      given precedence over locality.
  428.  
  429.      Since filling up this structure with mostly default values is a common
  430.      operation, we provide a special call to pre-fill this structure with
  431.      default values:
  432.  
  433.                void pm_filldefault(policy_set_t* policy_set);
  434.  
  435.  
  436.      The pm_create call returns a handle to the Policy Module just created, or
  437.      a negative long integer in case of error, in which case errno is set to
  438.      the corresponding error code. The handle returned by pm_create is of type
  439.      pmo_handle_t. The acronym PMO stands for Policy Management Object. This
  440.      type is common for all handles returned by all the Memory Management
  441.      Control Interface calls. These handles are used to identify the different
  442.      memory control objects created for an address space, much in the same way
  443.      as file descriptors are used to identify open files or devices. Every
  444.      address space contains one independent PMO table. A new table is created
  445.      only when a process execs.
  446.  
  447.      A simpler way to create a Policy Module is to used the restricted Policy
  448.      Module creation call:
  449.  
  450.                pmo_handle_t pm_create_simple(char* plac_name,
  451.                                              void* plac_args,
  452.                                              char* repl_name,
  453.                                              void* repl_args,
  454.                                              size_t page_size);
  455.  
  456.  
  457.      This call allows for the specification of only the Placement Policy, the
  458.      Replication Policy and the Page Size. Defaults are automatically chosen
  459.      for the Fallback Policy, the Migration Policy, and the Paging Policy.
  460.  
  461.  
  462.  
  463.                                                                         PPPPaaaaggggeeee 7777
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  471.  
  472.  
  473.  
  474.    AAAAssssssssoooocccciiiiaaaattttiiiioooonnnn ooooffff VVVViiiirrrrttttuuuuaaaallll AAAAddddddddrrrreeeessssssss SSSSppppaaaacccceeee SSSSeeeeccccttttiiiioooonnnnssss
  475.      The Memory Management Control Interface allows users to select different
  476.      policies for different sections of a virtual address space, down to the
  477.      granularity of a page. To associate a virtual address space section with
  478.      a set of policies, users need to first create a Policy Module with the
  479.      wanted policies, as described in the previous section, and then use the
  480.      following MMCI call:
  481.  
  482.           int pm_attach(pmo_handle_t pm_handle, void* base_addr, size_t
  483.           length);
  484.  
  485.      The ppppmmmm____hhhhaaaannnnddddlllleeee identifies the Policy Module the user has previously
  486.      created, bbbbaaaasssseeee____aaaaddddddddrrrr is the base virtual address of the virtual address
  487.      space section the user wants to associate to the set of policies, and
  488.      lllleeeennnnggggtttthhhh is the length of the section.
  489.  
  490.      All physical memory allocated on behalf of a virtual address space
  491.      section with a newly attached policy module follows the policies
  492.      specified by this policy module. Physical memory that has already been
  493.      allocated is not affected until the page is either migrated or swapped
  494.      out to disk and then brought back into memory.
  495.  
  496.      Only existing address space mappings are affected by this call. For
  497.      example, if a file is memory-mapped to a virtual address space section
  498.      for which a policy module was previously associated via ppppmmmm____aaaattttttttaaaacccchhhh, the
  499.      default policies will be applied rather than those specified by the
  500.      ppppmmmm____aaaattttttttaaaacccchhhh call.
  501.  
  502.  
  503.    DDDDeeeeffffaaaauuuulllltttt PPPPoooolllliiiiccccyyyy MMMMoooodddduuuulllleeee
  504.      A new Default Policy Module is created and inserted in the PMO Name Space
  505.      every time a process execs. This Default PM is used to define memory
  506.      management policies for all freshly created memory regions. This Default
  507.      PM can be later overridden by users via the pm_attach MMCI call.  This
  508.      Default Policy Module is created with the policies listed below:
  509.  
  510.      * PlacementDefault
  511.  
  512.      * FallbackDefault
  513.  
  514.      * ReplicationDefault
  515.  
  516.      * MigrationDefault
  517.  
  518.      * PagingDefault
  519.  
  520.      * Page size: 16KB
  521.  
  522.      * Flags: 0
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.                                                                         PPPPaaaaggggeeee 8888
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  537.  
  538.  
  539.  
  540.      The Default Policy Module is used in the following situations:
  541.  
  542.      - At exec time, when we create the basic memory regions for the stack,
  543.        text, and heap.
  544.  
  545.      - At fork time, when we create all the private memory regions.
  546.  
  547.      - At sproc time, when we create all the private memory regions (at least
  548.        the stack when the complete address space is shared).
  549.  
  550.      - When mmapping a file or a device.
  551.  
  552.      - When growing the stack and we find that the stack's region has been
  553.        removed by the user via unmap, or the user has done a setcontext,
  554.        moving the stack to a new location.
  555.  
  556.      - When sbreaking and we find the user has removed the associated region
  557.        using munmap, or the region was not growable, anonymous or copy-on-
  558.        write.
  559.  
  560.      - When a process attaches a portion of the address space of a "monitored"
  561.        process via procfs, and a new region needs to be created.
  562.  
  563.      - When a user attaches a SYSV shared memory region.
  564.  
  565.      The Default Policy Module is also stored in the per-process group PMO
  566.      Name space, and therefore follows the same inheritance rules as all
  567.      Policy Modules:  it is inherited at fork or sproc time, and a new one is
  568.      created at exec time.
  569.  
  570.      Users can select a new default policy module for the stack, text, and
  571.      heap:
  572.  
  573.                pmo_handle_t
  574.                pm_setdefault(pmo_handle_t pm_handle, mem_type_t mem_type);
  575.  
  576.  
  577.      The argument pm_handle is the handle returned by pm_create. The argument
  578.      mem_type is used to identify the memory section the user wants to change
  579.      the default policy module for, and it can take any of the following 3
  580.      values:
  581.  
  582.      +o MEM_STACK
  583.  
  584.      +o MEM_TEXT
  585.  
  586.      +o MEM_DATA
  587.  
  588.      Users can also obtain a handle to the default PM using the following
  589.      call:
  590.  
  591.  
  592.  
  593.  
  594.  
  595.                                                                         PPPPaaaaggggeeee 9999
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  603.  
  604.  
  605.  
  606.                pmo_handle_t pm_getdefault(mem_type_t mem_type);
  607.  
  608.  
  609.      This call returns a PMO handle referring to the calling process's address
  610.      space default PM for the specified memory type. The handle is greater or
  611.      equal to zero when the call succeeds, and it's less than zero when the
  612.      call fails, and errno is set to the appropriate error code.
  613.  
  614.    DDDDeeeessssttttrrrruuuuccccttttiiiioooonnnn ooooffff aaaa PPPPoooolllliiiiccccyyyy MMMMoooodddduuuulllleeee
  615.      Policy Modules are automatically destructed when all the members of a
  616.      process group or a shared group have died. However, users can explicitly
  617.      ask the operating system to destroy Policy Modules that are not in use
  618.      anymore, using the following call:
  619.  
  620.                int pm_destroy(pmo_handle_t pm_handle);
  621.  
  622.  
  623.      The argument pm_handle is the handle returned by pm_create. Any
  624.      association to this PM that already exists will remain effective, and the
  625.      PM will only be destroyed when the section of the address space that is
  626.      associated to this PM is also destroyed (unmapped), or when the
  627.      association is overridden via a pm_attach call.
  628.  
  629.    PPPPoooolllliiiiccccyyyy SSSSttttaaaattttuuuussss ooooffff aaaannnn AAAAddddddddrrrreeeessssssss SSSSppppaaaacccceeee
  630.      Users can obtain the list of policy modules currently associated to a
  631.      section of a virtual address space using the following call:
  632.  
  633.                typedef struct pmo_handle_list {
  634.                        pmo_handle_t* handles;
  635.                        uint          length;
  636.                } pmo_handle_list_t;
  637.  
  638.                int pm_getall(void* base_addr,
  639.                              size_t length,
  640.                              pmo_handle_list_t* pmo_handle_list);
  641.  
  642.  
  643.  
  644.      The argument base_addr is the base address for the section the user is
  645.      inquiring about, length is the length of the section, and pmo_handle_list
  646.      is a pointer to a list of handles as defined by the structure
  647.      pmo_handle_list_t.
  648.  
  649.      On success, this call returns the effective number of PMs that are being
  650.      used by the specified virtual address space range. If this number is
  651.      greater than the size of the list to be used as a container for the PM
  652.      handles, the user can infer that the specified virtual address space
  653.      range is using more PM's than we can fit in the list. On failure, this
  654.      call returns a negative integer, and errno is set to the corresponding
  655.      error code.
  656.  
  657.  
  658.  
  659.  
  660.  
  661.                                                                        PPPPaaaaggggeeee 11110000
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  669.  
  670.  
  671.  
  672.      Users also have read-only access to the internal details of a PM, using
  673.      the following call:
  674.  
  675.                typedef struct pm_stat {
  676.                        char         placement_policy_name[PM_NAME_SIZE + 1];
  677.                        char         fallback_policy_name[PM_NAME_SIZE + 1];
  678.                        char         replication_policy_name[PM_NAME_SIZE + 1];
  679.                        char         migration_policy_name[PM_NAME_SIZE + 1];
  680.                        char         paging_policy_name[PM_NAME_SIZE + 1];
  681.                        size_t       page_size;
  682.                        int          policy_flags;
  683.                        pmo_handle_t pmo_handle;
  684.                } pm_stat_t;
  685.  
  686.                int pm_getstat(pmo_handle_t pm_handle, pm_stat_t* pm_stat);
  687.  
  688.  
  689.      The argument pm_handle identifies the PM the user needs information
  690.      about, and pm_stat is an out parameter of the form defined by the
  691.      structure pm_stat_t.  On success this call returns a non-negative
  692.      integer, and the PM internal data in pm_stat. On error, the call returns
  693.      a negative integer, and errno is set to the corresponding error code.
  694.  
  695.    SSSSeeeettttttttiiiinnnngggg tttthhhheeee PPPPaaaaggggeeee SSSSiiiizzzzeeee
  696.      Users can modify the page size of a PM using the following MMCI call:
  697.  
  698.                int pm_setpagesize(pmo_handle_t pm_handle, size_t page_size);
  699.  
  700.  
  701.      The argument pm_handle identifies the PM the user is changing the page
  702.      size for, and the argument page_size is the requested page size. This
  703.      call changes the page size for the PM's associated with the specified
  704.      section of virtual address space so that newly allocated memory will use
  705.      the new page size.  On success this call returns a non-negative integer,
  706.      and on error, it returns a negative integer with errno set to the
  707.      corresponding error code.
  708.  
  709.    LLLLooooccccaaaalllliiiittttyyyy MMMMaaaannnnaaaaggggeeeemmmmeeeennnntttt
  710.      One of the most important goals of memory management in a CCNUMA system
  711.      like the Origin 2000 is the maximization of locality. IRIX uses several
  712.      mechanisms to manage locality:
  713.  
  714.      +o IRIX implements dynamic memory migration to automatically attract
  715.        memory to those processes that are making the heaviest use of a page of
  716.        memory.
  717.  
  718.      +o IRIX replicates read-only memory sections, such as application and
  719.        library code, in order to maximize local memory accesses and avoid
  720.        interconnect contention.
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.                                                                        PPPPaaaaggggeeee 11111111
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  735.  
  736.  
  737.  
  738.      +o IRIX schedules memory in such a way that applications can allocate
  739.        large amounts of relatively close memory pages.
  740.  
  741.      +o IRIX does topology aware initial memory placement.
  742.  
  743.      +o IRIX provides a topology aware process scheduler that integrates cache
  744.        and memory affinity into the scheduling algorithms.
  745.  
  746.      +o IRIX allows and encourages application writers to provide initial
  747.        placement hints, using high level tools, compiler directives, or direct
  748.        system calls.
  749.  
  750.      +o IRIX allows users to select different policies for the most important
  751.        memory management operations.
  752.  
  753.    TTTThhhheeee PPPPllllaaaacccceeeemmmmeeeennnntttt PPPPoooolllliiiiccccyyyy
  754.      The Placement Policy defines the algorithm used by the physical memory
  755.      allocator to decide what memory source to use to allocate a page in a
  756.      multi-node CCNUMA machine. The goal of this algorithm is to place memory
  757.      in such a way that local accesses are maximized.
  758.  
  759.      The optimal placement algorithm would have knowledge of the exact number
  760.      of cache misses that will be caused by each thread sharing the page to be
  761.      placed.  Using this knowledge, the algorithm would place the page on the
  762.      node currently running the thread that will generate most cache misses,
  763.      assuming that the thread always stays on the same node.
  764.  
  765.      Unfortunately, we don't have perfect knowledge of the future. The
  766.      algorithm has to be based on heuristics that predict the memory access
  767.      patterns and cache misses on a page, or on user provided hints.
  768.  
  769.      All placement policies are based on two abstractions of physical memory
  770.      nodes:
  771.  
  772.      +o Memory Locality Domains (MLDs)
  773.  
  774.      +o Memory Locality Domain Sets (MLDsets)
  775.  
  776.    MMMMeeeemmmmoooorrrryyyy LLLLooooccccaaaalllliiiittttyyyy DDDDoooommmmaaaaiiiinnnnssss
  777.      A Memory Locality Domain or MLD with center c and radius r is a source of
  778.      physical memory composed of all memory nodes within a "hop distance" r of
  779.      a center node c. Normally, MLDs have radius 0,representing one single
  780.      node.
  781.  
  782.      MLDs may be interpreted as virtual memory nodes. Normally the application
  783.      writer defining MLDs specifies the MLD radius, and lets the operating
  784.      system decide where it will be centered. The operating system tries to
  785.      choose a center according to current memory availability and other
  786.      placement parameters that the user may have specified such as device
  787.      affinity and topology.
  788.  
  789.  
  790.  
  791.  
  792.  
  793.                                                                        PPPPaaaaggggeeee 11112222
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  801.  
  802.  
  803.  
  804.      Users can create MLDs using the following MMCI call:
  805.  
  806.                pmo_handle_t mld_create(int radius, long size);
  807.  
  808.  
  809.      The argument radius defines the MLD radius, and the argument size is a
  810.      hint specifying approximately how much physical memory will be required
  811.      for this MLD.  On success this call returns a handle for the newly
  812.      created MLD. On error, this call returns a negative long integer and
  813.      errno is set to the corresponding error code.
  814.  
  815.      MLDs are not placed when they are created. The MLD handle returned by the
  816.      constructor cannot be used until the MLD has been placed by making it
  817.      part of an MLDset.
  818.  
  819.      Users can also destroy MLDs not in use anymore using the following call:
  820.  
  821.                int mld_destroy(pmo_handle_t mld_handle);
  822.  
  823.  
  824.      The argument mld_handle is the handle returned by mld_create. On success,
  825.      this call returns a non-negative integer. On error it returns a negative
  826.      integer and errno is set to the corresponding error code.
  827.  
  828.    MMMMeeeemmmmoooorrrryyyy LLLLooooccccaaaalllliiiittttyyyy DDDDoooommmmaaaaiiiinnnn SSSSeeeettttssss
  829.      Memory Locality Domain Sets or MLDsets address the issue of placement
  830.      topology and device affinity.
  831.  
  832.      Users can create MLDsets using the following MMCI call:
  833.  
  834.           pmo_handle_t mldset_create(pmo_handle_t* mldlist, int mldlist_len);
  835.  
  836.      The argument mldlist is an array of MLD handles containing all the MLD's
  837.      the user wants to make part of the new MLDset, and the argument
  838.      mldlist_len is the number of MLD handles in the array. On success, this
  839.      call returns an MLDset handle. On error, this call returns a negative
  840.      long integer and errno is set to the corresponding error code.
  841.  
  842.      This call only creates a basic MLDset without any placement information.
  843.      An MLDset in this state is useful just to specify groups of MLDs that
  844.      have already been placed. In order to have the operating system place
  845.      this MLDset, and therefore place all the MLDs that are now members of
  846.      this MLDset, users have to specify the wanted MLDset topology and device
  847.      affinity, using the following MMCI call:
  848.  
  849.                int mldset_place(pmo_handle_t mldset_handle,
  850.                                 topology_type_t topology_type,
  851.                                 raff_info_t* rafflist,
  852.                                 int rafflist_len,
  853.                                 rqmode_t rqmode);
  854.  
  855.  
  856.  
  857.  
  858.  
  859.                                                                        PPPPaaaaggggeeee 11113333
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  867.  
  868.  
  869.  
  870.      The argument mldset_handle is the MLDset handle returned by
  871.      mldset_create, and identifies the MLDset the user is placing. The
  872.      argument topology_type specifies the topology the operating system should
  873.      consider in order to place this MLDset, which can be one of the
  874.      following:
  875.  
  876.      TOPOLOGY_FREE        This topology specification lets the Operating
  877.                           System decide what shape to use to allocate the set.
  878.                           The Operating System will try to place this MLDset
  879.                           on a cluster of physical nodes as compact as
  880.                           possible, depending on the current system load.
  881.  
  882.      TOPOLOGY_CUBE        This topology specification is used to request a
  883.                           cube-like shape.
  884.  
  885.      TOPOLOGY_CUBE_FIXED  This topology specification is used to request a
  886.                           physical cube.
  887.  
  888.      TOPOLOGY_PHYSNODES   This topology specification is used to request that
  889.                           the MLDs in an MLDset be placed in the exact
  890.                           physical nodes enumerated in the device affinity
  891.                           list, described below.
  892.  
  893.      TOPOLOGY_CPUCLUSTER  This topology specification is used to request the
  894.                           placement of one MLD per CPU instead of the default
  895.                           one MLD per node. In an Origin 3000, the number of
  896.                           cpus on a fully populated node is 4, hence each node
  897.                           can have up to 4 MLDs placed per node. For a node
  898.                           with less than the maximum number of cpus available
  899.                           the number of MLDs placed on that node will not
  900.                           exceed the actual number of CPUs. Also if cpusets
  901.                           are in use, the MLDs will be placed on nodes that
  902.                           are part of the defined cpuset.  This topology is
  903.                           useful when the placement policy is managing cache
  904.                           coloring relative to MLDs instead of virtual memory
  905.                           regions.
  906.  
  907.      The topology_type_t type shown below is defined in <sys/pmo.h>.
  908.  
  909.           /*
  910.            * Topology types for mldsets
  911.            */
  912.           typedef enum {
  913.                   TOPOLOGY_FREE,
  914.                   TOPOLOGY_CUBE,
  915.                   TOPOLOGY_CUBE_FIXED,
  916.                   TOPOLOGY_PHYSNODES,
  917.                   TOPOLOGY_CPUCLUSTER,
  918.                   TOPOLOGY_LAST
  919.           } topology_type_t;
  920.  
  921.  
  922.  
  923.  
  924.  
  925.                                                                        PPPPaaaaggggeeee 11114444
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  933.  
  934.  
  935.  
  936.      The argument rafflist is used to specify resource affinity. It is an
  937.      array of resource specifications using the structure shown below:
  938.  
  939.           /*
  940.            * Specification of resource affinity.
  941.            * The resource is specified via a
  942.            * file system name (dev, file, etc).
  943.           */
  944.           typedef struct raff_info {
  945.                void* resource;
  946.                ushort reslen;
  947.                ushort restype;
  948.                ushort radius;
  949.                ushort attr;
  950.           } raff_info_t;
  951.  
  952.  
  953.  
  954.      The fields resource, reslen, and restype define the resource. The field
  955.      resource is used to specify the name of the resource, the field reslen
  956.      must always be set to the actual number of bytes the resource pointer
  957.      points to, and the field restype specifies the kind of resource
  958.      identification being used, which can be any of the following:
  959.  
  960.      RAFFIDT_NAME This resource identification type should be used for the
  961.                   cases where a hardware graph path name is used to identify
  962.                   the device.
  963.  
  964.      RAFFIDT_FD   This resource identification type should be used for the
  965.                   cases where a file descriptor is being used to identify the
  966.                   device.
  967.  
  968.      The radius field defines the maximum distance from the actual resource
  969.      the user would like the MLDset to be place at. The attr field specified
  970.      whether the user wants the MLDset to be placed close or far from the
  971.      resource:
  972.  
  973.      RAFFATTR_ATTRACTION The MLDset should be placed as close as possible to
  974.                          the specified device.
  975.  
  976.      RAFFATTR_REPULSION  The MLDset should be placed as far as possible from
  977.                          the specified device.
  978.  
  979.      The argument rafflist_len in the mldset_place call specifies the number
  980.      of raff structures the user is passing via rafflist. There must be at
  981.      least as many raff structures passed as the size of the corresponding
  982.      mldset or the operation will fail and EINVAL will be returned.
  983.  
  984.      Finally, the rqmode argument is used to specify whether the placement
  985.      request is ADVISORY or MANDATORY:
  986.  
  987.  
  988.  
  989.  
  990.  
  991.                                                                        PPPPaaaaggggeeee 11115555
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  999.  
  1000.  
  1001.  
  1002.           /*
  1003.            * Request types
  1004.            */
  1005.           typedef enum {
  1006.                   RQMODE_ADVISORY,
  1007.                   RQMODE_MANDATORY
  1008.           } rqmode_t;
  1009.  
  1010.  
  1011.      The Operating System places the MLDset by finding a section of the
  1012.      machine that meets the requirements of topology, device affinity, and
  1013.      expected physical memory used.
  1014.  
  1015.      The mldset_place call returns a non-negative integer on success. On
  1016.      error, it returns a negative integer and errno is set to the
  1017.      corresponding error code.
  1018.  
  1019.      Users can destroy MLDsets using the following call:
  1020.  
  1021.           int mldset_destroy(pmo_handle_t mldset_handle);
  1022.  
  1023.  
  1024.      The argument mldset_handle identifies the MLDset to be destroyed. On
  1025.      success, this call returns a non-negative integer. On error it returns a
  1026.      negative integer and errno is set to the corresponding error code.
  1027.  
  1028.    LLLLiiiinnnnkkkkiiiinnnngggg EEEExxxxeeeeccccuuuuttttiiiioooonnnn TTTThhhhrrrreeeeaaaaddddssss ttttoooo MMMMLLLLDDDDssss
  1029.      After creating MLDs and placing them using an MLDset, a user can create a
  1030.      Policy Module that makes use of these memory sources, and attach sections
  1031.      of a virtual address space to this Policy Module.
  1032.  
  1033.      We still need to make sure that the application threads will be executed
  1034.      on the nodes where we are allocating memory. To ensure this, users need
  1035.      to link threads to MLDs using the following call:
  1036.  
  1037.           int process_mldlink(pid_t pid, pmo_handle_t mld_handle);
  1038.  
  1039.  
  1040.      The argument pid is the pid of the process to be linked to the MLD
  1041.      specified by the argument mld_handle. On success this call return a non-
  1042.      negative integer.  On error it returns a negative integer and errno is
  1043.      set to the corresponding error code.
  1044.  
  1045.      This call sets up a hint for the process scheduler. However, the process
  1046.      scheduler is not required to always run the process on the node specified
  1047.      by the mld. The scheduler may decide to temporarily use different cpus in
  1048.      different nodes to execute threads to maximize resource utilization.
  1049.  
  1050.    NNNNaaaammmmeeee SSSSppppaaaacccceeeessss FFFFoooorrrr MMMMeeeemmmmoooorrrryyyy MMMMaaaannnnaaaaggggeeeemmmmeeeennnntttt CCCCoooonnnnttttrrrroooollll
  1051.      +o TTTThhhheeee PPPPoooolllliiiiccccyyyy NNNNaaaammmmeeee SSSSppppaaaacccceeee. This is a global system name space that contains
  1052.        all the policies that have been exported and therefore are available to
  1053.        users.  The domain of this name space is the set of exported policy
  1054.  
  1055.  
  1056.  
  1057.                                                                        PPPPaaaaggggeeee 11116666
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064. mmmmmmmmcccciiii((((5555))))                                                                mmmmmmmmcccciiii((((5555))))
  1065.  
  1066.  
  1067.  
  1068.        names, strings of characters such as "PlacementDefault", and its range
  1069.        is the corresponding set of policy constructors. When a user creates a
  1070.        policy module, he or she has to specify the policies for all selectable
  1071.        policies by name. Internally, the operating system searches for each
  1072.        name in the Policy Name Space, thereby getting hold of the constructors
  1073.        for each of the specified policies, which are used to initialize the
  1074.        actual internal policy modules.
  1075.  
  1076.      +o TTTThhhheeee PPPPoooolllliiiiccccyyyy MMMMaaaannnnaaaaggggeeeemmmmeeeennnntttt OOOObbbbjjjjeeeecccctttt NNNNaaaammmmeeee SSSSppppaaaacccceeee. This is a per-process group,
  1077.        either shared (sprocs) or not shared (forks), name space used to store
  1078.        handles for all the Policy Management Objects that have been created
  1079.        within the context of any of the members of the process group. The
  1080.        domain of this name space is the set of Policy Management Object (PMO)
  1081.        handles and its range is the set of references (internal kernel
  1082.        pointers) to the PMO's.
  1083.  
  1084.        PMO handles can refer to any of several kinds of Policy Management
  1085.        Objects:
  1086.  
  1087.        - Policy Modules
  1088.  
  1089.        - Memory Locality Domains (MLDs)
  1090.  
  1091.        - Memory Locality Domain Sets (MLDsets)
  1092.  
  1093.      The PMO Name Space is inherited at fork or sproc time, and created at
  1094.      exec time.
  1095.  
  1096. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  1097.      numa(5), migration(5), mtune(4), /var/sysgen/mtune/numa, refcnt(5),
  1098.      replication(5), nstats(1), sn(1), mld(3c), mldset(3c), pm(3c),
  1099.      migration(3c), pminfo(3c), numa_view(1), dplace(1), dprof(1).
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.                                                                        PPPPaaaaggggeeee 11117777
  1124.  
  1125.  
  1126.  
  1127.